package com.magnificent.atlantis.client.data.task.common;

import com.magnificent.commons.utils.TimeConstants;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.ArrayList;
import java.util.List;

/**
 * User: Babanin
 * Date: 21.03.2009
 * Time: 2:49:41
 */
@XmlRootElement(name = "task")
public abstract class AbstractTask {

    private static int uniqueId = 0;

    private int id;
    private String name;
    private String description;

    private int dependencyTaskId;
    private long dependencyTaskTime;

    private long duration;
    private TaskImportance taskImportance;

    private List<Integer> dependencyTasks;

    private int configurationId;

    protected AbstractTask() {
        id = uniqueId++;
        description = "";
        configurationId = -1;
        name = "Task #" + id;
        dependencyTaskId = -1;
        dependencyTaskTime = 0;
        duration = TimeConstants.MLS_IN_HOUR;
        taskImportance = TaskImportance.NORMAL;
        dependencyTasks = new ArrayList<Integer>();
    }

    @XmlAttribute()
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @XmlElement()
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @XmlElement()
    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @XmlAttribute()
    public int getDependencyTaskId() {
        return dependencyTaskId;
    }

    public void setDependencyTaskId(int dependencyTaskId) {
        this.dependencyTaskId = dependencyTaskId;
    }

    @XmlAttribute()
    public long getDependencyTaskTime() {
        return dependencyTaskTime;
    }

    public void setDependencyTaskTime(long dependencyTaskTime) {
        this.dependencyTaskTime = dependencyTaskTime;
    }

    @XmlElement()
    public List<Integer> getDependencyTasks() {
        return dependencyTasks;
    }

    public void setDependencyTasks(List<Integer> dependencyTasks) {
        this.dependencyTasks = dependencyTasks;
    }

    @XmlAttribute()
    public int getConfigurationId() {
        return configurationId;
    }

    public void setConfigurationId(int configurationId) {
        this.configurationId = configurationId;
    }

    @XmlAttribute()
    public long getDuration() {
        return duration;
    }

    public void setDuration(long duration) {
        this.duration = duration;
    }

    @XmlAttribute()
    public TaskImportance getTaskImportance() {
        return taskImportance;
    }

    public void setTaskImportance(TaskImportance taskImportance) {
        this.taskImportance = taskImportance;
    }

    @Override
    public String toString() {
        return name;
    }
}
